import { LinkeCurrency } from "./CheartConfig";
//图表类
class Chart {
    private chart: echarts.ECharts;
    constructor(element: HTMLDivElement | HTMLCanvasElement) {
        // console.log('yzt', element);
        this.chart = echarts.init(element);
        setTimeout(() => {
            this.chart.getDom().children[1].className = "tips";
        }, 100);
    }
    //拿去chart实例
    getChart() {
        return this.chart;
    }
    //设置图表数据
    setData(option: echarts.EChartOption) {
        this.chart.setOption(option);
    }
    chartResize() {
        if (this.chart) {
            this.chart.resize();
            setTimeout(() => {
                this.chart.resize();
            }, 300);
        }
    }
    static addChart(dom: HTMLElement | HTMLCanvasElement) {
        const chart = new Chart(dom as any);
        chart.setData(LinkeCurrency as any);
        return chart;
    }
}

export { Chart };
